.\" -*- nroff -*-
.TH register_chrdev 9 "$Date:$" "Linux 2.0" "Kernel Functions"
.SH NAME
register_chrdev, unregister_chrdev \- register a driver major number
.SH SYNOPSIS
.B #include <linux/fs.h>
.sp
.BI "int register_chrdev(unsigned int " major ", const char*" name ","
.BI "struct file_operations*" ops ");"
.br
.BI "int unregister_chrdev(unsigned int " major ", const char *" name ");"
.SH DESCRIPTION
The
.B register_chrdev
function associates a character major number with set of driver entry
points. The file_operations structure contains pointers to functions
that the the driver uses to implement the kernel interface to the
driver.
.PP
The paramter
.I major
is the character major number assigned to the device driver and to be
mapped to the function table. The
.I name
parameter is a short name for the device and is displayed in the
The
.I "/proc/devices"
list. It also must exactly match the name passed to
.B unregister_chrdev
function when releasing the functions.
.PP
A device driver module may register as many different major numbers as
it supports, though this is not typically done.
.PP
The
.B unregister_chrdev
function releases the major number, and is normally called in the
module_cleanup function to remove the driver from the kernel.
.SH "RETURN VALUE"
On success,
.B register_chrdev
returns 0 if
.I major
is a number other then 0, otherwise Linux will choose a major number
and return the chosen value.
.PP
If there is an error, one of the following codes is returned instead:
.RS
.TP
-EINVAL
The specified number is not valid (> MAX_CHRDEV)
.TP
-EBUSY
The major number is busy
.RE
.PP
The
.B unregister_chrdev
function will return 0 if successful, or
.B "-EINVAL"
if the major number is not registered with the matching name.
.SH AVAILABILITY
Linux 1.0+
.SH "SEE ALSO"
.BR register_blkdev "(9) " mknod "(2)"
.SH AUTHOR
Stephen Williams (steve@icarus.com)
.SH BUGS
